/**
 * @Author:高志斐
 * @Date:2020/7/2
 * @Description:这是风险测评结果页面
 */
import React,{Component} from "react";
import {Button, Icon, NavBar, WhiteSpace} from "antd-mobile";
import axios from "axios";
import {URL} from "../../index";
import {getCookieId, setRiskCookie} from "../Login/Component_Login/GetCookie";

export default class RiskLevelReturn extends Component{
    constructor(props) {
        super(props);
        this.state = {
            riskLevel:"",//风险类型
            riskDetail:""//详细描述
        };
        this.handleClick=this.handleClick.bind(this)
        this.handleLeftClick=this.handleLeftClick.bind(this)
    }
    handleClick(){
        localStorage.setItem('tabs',2);
        this.props.history.push("/terran/my")
    }
    //设置缓存，返回到我的页
    handleLeftClick(event){
        localStorage.setItem('tabs',2);
        this.props.history.push('/terran/my')
    }
    //加载风险测评结果
    componentWillMount() {
        axios({
            method:"GET",
            url:URL+"/userInfo/getRiskLevel",
            params:{userId: getCookieId()},
        }).then(res=>{
            this.setState({
                riskLevel:res.data.riskLevel,
                riskDetail:res.data.info
            })
        }).catch(error=>{
            console.log(error);
        })
    }
    render() {
        return(
                <div className='linear' >
                    {/*顶部导航栏*/}
                    <NavBar
                        mode="light"
                        icon={<Icon type="left" style={{color:"#f8a83f"}}/>}
                        onLeftClick={this.handleLeftClick}
                    >风险测评结果</NavBar>

                    <div className='risk-level-container' style={{width:"80%",height:"80%"}}>
                        <div style={{padding:' 100px 0px 15px 15px'}}>
                            <h1>您的风险类型是</h1>
                        </div>
                        <div style={{padding:"0px 15px",color:'#108ee9',fontSize:"50px",height:"10%"}}>
                            {this.state.riskLevel}
                        </div>
                        <WhiteSpace />
                        <div style={{padding:'  20px 15px ',fontSize:"15px"}}>
                            {this.state.riskDetail}
                        </div>
                        <Button style={{backgroundColor:"#f8a83f",width:"60%",margin:"0 auto",marginTop:"80px",color:"#FFFFFF"}} onClick={this.handleClick}>完成</Button>
                    </div>
                </div>
        );
    }
}
